﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WuxiWTO.Mapping;
using WutiWTO.Common;
using System.Text;

namespace WuxiWTO.Web
{
    public partial class flashnews : System.Web.UI.Page
    {
        protected string article_title = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int aid = 0;
                if (!string.IsNullOrEmpty(Request.QueryString["id"]))
                {
                    int.TryParse(Request.QueryString["id"], out aid);
                    InitArtcileTitle(aid);
                    GetArtContent(aid);
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "paramerr", "alert('参数传递失败');location='default.aspx';", true);
                }
            }
        }

        private void InitArtcileTitle(int aid)
        {
            string articleTitle = Utility.GetDescByIDFromXML(Server.MapPath("~/metadate/flasharticle.xml"), aid.ToString());
            this.litBreakCrumbs.Text = "<a href='flasharticle.aspx?id=" + aid + "'>" + articleTitle + "</a>";
            article_title = articleTitle;
        }

        private void GetArtContent(int aid)
        {
            WTODataContext ctx = new WTODataContext();
            flash_article art = ctx.flash_articles.FirstOrDefault(p => p.ID == aid);
            if (art != null)
            {
                this.litContent.Text = art.content;
            }
        }
    }
}